Release 10.1A: OpenEdge Getting Started:
Object-oriented Programming


Comparing objects

You can compare two object references for equality using the equals operator (=), which checks if two object references are actually referencing the same object. The object references can be equal even if the object references have been defined for different classes in the class hierarchy. Two object references are also equal if they are both the Unknown value (?).

The following example demonstrates the use of the equal operator usin the two object references, rSuper and rSubClass:

DEFINE VARIABLE rSubClass AS CLASS SubClass NO-UNDO. 
DEFINE VARIABLE rSuper    AS CLASS SuperClass NO-UNDO. 
rSubClass = NEW SubClass ( ). 
rSuper = rSubClass. 
IF rSuper = rSubClass THEN 
    MESSAGE "they are the SAME". 

The MESSAGE statement will indeed be executed, demonstrating that rSuper and rSubClass are equal even though they are defined as different classes in the class hierarchy.


Copyright © 2005 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095